# coding=utf-8
from django.db import models

class ModelExtendManager(models.Manager):
    def getGridDict(self,start=0,limit=10):
        import datetime,decimal
        count = self.all().count()
        items = self.all()[start:limit].values()
        for item in list(items):
            for key in item.keys():
                if isinstance(item[key], datetime.datetime):  
                    item[key] =  item[key].strftime('%Y-%m-%d %H:%M:%S')
                elif isinstance(item[key], datetime.time):  
                    item[key] =  item[key].strftime('%H:%M:%S')
                elif isinstance(item[key], datetime.date):  
                    item[key] =  item[key].strftime('%Y-%m-%d')
                elif isinstance(item[key], decimal.Decimal):  
                    item[key] = str(item[key])  
                    
        return {'count':count,'items':list(items)}
    